package com.yungu.swift.order.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.PageVo;
import com.yungu.swift.order.dao.OrderMapper;
import com.yungu.swift.order.model.param.OrderReturnVisitParam;
import com.yungu.swift.order.model.vo.AdminOrderReturnVisitVo;
import com.yungu.swift.order.service.OrderReturnVisitService;
import com.yungu.swift.utils.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

@Service
public class OrderReturnVisitServiceImpl implements OrderReturnVisitService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public ResponseData<PageVo<AdminOrderReturnVisitVo>> queryFirstOrderInfo(OrderReturnVisitParam orderReturnVisitParam) {
        PageBounds pageBounds = new PageBounds(orderReturnVisitParam.getPageNum(), orderReturnVisitParam.getPageSize());
        Map<String, Object> paraMap = MapUtils.convertObjToMap(orderReturnVisitParam);
        PageList<AdminOrderReturnVisitVo> resultList = orderMapper.queryFirstOrderInfo(paraMap, pageBounds);
        PageVo<AdminOrderReturnVisitVo> pageVo = new PageVo(orderReturnVisitParam.getPageNum(), orderReturnVisitParam.getPageSize(),
                resultList.getPaginator().getTotalCount());
        pageVo.setItems(resultList);
        return ResponseData.buildSuccessResponse(pageVo);
    }

}
